"use strict";
cc._RF.push(module, '96d31lIojlP/YHg81gnuR3I', 'PromoDrawer');
// scripts/PromoDrawer.js

"use strict";

var e = require;
var t = module;
var n = exports;
Object.defineProperty(n, "__esModule", {
  value: !0
});

var o = e("PromoNodeArrItem"),
    i = cc._decorator,
    a = i.ccclass,
    r = i.property,
    s = function (e) {
  __extends(t, e);

  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.mDatas = null;
    t.itemList = [];
    t.prefab = null;
    t.layout = null;
    t.move = null;
    t.show = null;
    t.hide = null;
    t.maskNode = null;
    t.maxX = 640;
    t.oppoClose = !1;
    t.targetX = 0;
    return t;
  }

  t.prototype.onLoad = function () {
    SDK.Base.Event.on("getData", this.initData, this);
    this.initData();
  };

  t.prototype.onDestroy = function () {
    SDK.Base.Event.off("getData", this.initData, this);
  };

  t.prototype.initData = function () {
    if (SDK.Mgr.Inst.hasPromoData) {
      if (SDK.Mgr.Inst.curChannel == SDK.Define.Channel.oppo) {
        if (this.oppoClose && !SDK.Mgr.Inst.isAdOpen) this.node.active = !1;else {
          this.node.active = !0;
          this.mDatas = Config.Base.promoData;
          this.setData();
        }
      } else {
        this.node.active = !0;
        this.mDatas = Config.Base.promoData;
        this.setData();
      }
    } else this.node.active = !1;
  };

  t.prototype.setData = function () {
    if (this.mDatas.content.length > 0) for (var e = 0; e < Math.min(this.mDatas.content.length, 9); e++) {
      var t = cc.instantiate(this.prefab);
      t.parent = this.layout;
      t.active = !0;
      var n = t.getComponent(o["default"]);
      null != n && this.itemList.push(n);
      n.setData(this.mDatas.content[e]);
    }
  };

  t.prototype.Show = function () {
    this.targetX = this.maxX;
    this.show.active = !1;
    this.hide.active = !0;

    if (this.maskNode) {
      this.maskNode.active = !0;
      this.maskNode.opacity = 0;
      this.maskNode.runAction(cc.fadeTo(.3, 180));
    }
  };

  t.prototype.Hide = function () {
    var e = this;
    this.targetX = 0;
    this.maskNode && this.maskNode.runAction(cc.sequence(cc.fadeOut(.3), cc.callFunc(function () {
      e.maskNode.active = !1;
    })));
  };

  t.prototype.update = function (e) {
    if (this.move.position.x != this.targetX) {
      var t = this.targetX - this.move.position.x,
          n = 3e3 * e;
      t = t > 0 ? Math.min(this.move.position.x + n, this.targetX) : Math.max(this.move.position.x - n, this.targetX);
      this.move.position = new cc.Vec3(t, 0);

      if (0 == this.move.position.x) {
        this.show.active = !0;
        this.hide.active = !1;
      }
    }
  };

  __decorate([r(cc.Node)], t.prototype, "prefab", void 0);

  __decorate([r(cc.Node)], t.prototype, "layout", void 0);

  __decorate([r(cc.Node)], t.prototype, "move", void 0);

  __decorate([r(cc.Node)], t.prototype, "show", void 0);

  __decorate([r(cc.Node)], t.prototype, "hide", void 0);

  __decorate([r(cc.Node)], t.prototype, "maskNode", void 0);

  __decorate([r(cc.Boolean)], t.prototype, "oppoClose", void 0);

  return __decorate([a], t);
}(cc.Component);

n["default"] = s;

cc._RF.pop();